<!-- BEGIN:main -->
<script type="text/javascript">

    function loadpage() {
        var dataString = 'action=view';
        var location = "index.php?com=com_dathang&view=view";
        $.ajax({
            type: "POST",
            url: location,
            data: dataString,
            cache: false,
            beforeSend: function()
            {
            },
            success: function(response) {

                $(".container").hide().fadeIn('fast').html(response);
                //self.location = location_succ;
            }
        });
    }
    function capnhattrangthai(trangthai) {
        var arrayID = '';
        $("input[name=cid[]]:checked").each(function(i) {
            var value = $(this).val();
            arrayID += value + ',';
        });
        var dataString = 'action=updatestatus&mangid=' + arrayID + "&trangthai=" + trangthai;
        var location = "index.php?com=com_dathang&view=view";
        $.ajax({
            type: "POST",
            url: location,
            data: dataString,
            cache: false,
            beforeSend: function()
            {
                if (trangthai == 'success') {
                    $("#btndagiao").html("Xin chờ");
                } else if (trangthai == 'warning') {
                    $("#btnlamxong").html("Xin chờ");
                } else if (trangthai == 'danger') {
                    $("#btnquahan").html("Xin chờ");
                } else {
                    $("#btnmoinhan").html("Xin chờ");
                }

            },
            success: function(response) {
                if (trangthai == 'success') {
                    $("#btndagiao").html("Đã Giao");
                } else if (trangthai == 'warning') {
                    $("#btnlamxong").html("Làm Xong");
                } else if (trangthai == 'danger') {
                    $("#btnquahan").html("Quá Hạn");
                } else {
                    $("#btnmoinhan").html("Mới Nhận");
                }
                window.location.reload();

            }
        });
    }
    function deleteitem(index) {
        var arrayID = '';
        $("input[name=cid[]]:checked").each(function(i) {
            var value = $(this).val();
            arrayID += value + ',';
        });
        var dataString = 'action=delete&mangid=' + arrayID;
        var location = "index.php?com=com_dathang&view=view";
        $.ajax({
            type: "POST",
            url: location,
            data: dataString,
            cache: false,
            beforeSend: function()
            {
                $("#btndel").html("Xin chờ");
            },
            success: function(response) {

                $("#btndel").html("Xóa");
                window.location.reload();
            }
        });
    }

    function callEdit() {
        var arrayID = '';
        var id=$("input[name=cid[]]:checked").val();        
        window.location.href = "index.php?com=com_dathang&view=update&action=update&id="+id;
    }
</script>
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">ĐẶT HỒ SƠ</h3>
    </div>
    <div class="panel-body">
        <div class="row">

            <div>
                <style>
                    .table{
                        font-size: 11px;
                    }
                </style>                
                <div class="row">
                    <div class="col-md-6">
                        <table class="table">
                            <tr>
                                <td colspan="4">Ghi chú</td>
                            </tr>
                            <tr height="20px">
                                <td class="active" width="5%">Mới nhận</td>                            
                                <td class="warning" width="5%">Làm xong</td>                            
                                <td class="success" width="5%">Đã giao</td>                            
                                <td class="danger" width="5%">Quá hạn</td>                                                                                    
                            </tr>                    
                        </table>
                    </div>

                    <div class="col-md-6">
                        <table class="table col-md-6">                        
                            <tr>
                                <td>Hồ Sơ Mới</td>
                                <td>Làm xong</td>
                                <td>Đã giao</td>
                                <td>Quá hạn</td>
                                <td>Hồ sơ màu</td>
                                <td>Trắng đen</td>
                                <td>Tổng Tiền</td>
                            </tr>
                            <tr>
                                <td>1</td>
                                <td>2</td>
                                <td>3</td>
                                <td>4</td>
                                <td>2</td>
                                <td>2</td>
                                <td>12131</td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="row">
                    <div style="float: right;padding-right: 20px">                   
                        <a href="index.php?com=com_dathang&view=add"><button type="button" class="btn btn-danger" onclick="" id="btndel">Thêm Mới</button></a>
                        <button class="btn btn-danger" id="create-user" onclick="callEdit();">Sửa</button>
                        <button type="button" class="btn btn-primary" onclick="deleteitem()" id="btndel">Xóa</button>
                        <button type="button" class="btn btn-success" onclick="capnhattrangthai('success')" id="btndagiao">Đã Giao</button>
                        <button type="button" class="btn btn-warning" onclick="capnhattrangthai('warning')" id="btnlamxong">Làm xong</button>
                        <button type="button" class="btn btn-danger" onclick="capnhattrangthai('danger')" id="btnquahan">Quá Hạn</button>
                        <button type="button" class="btn btn-default" onclick="capnhattrangthai('')" id="btnmoinhan">Mới Nhận</button>
                    </div>
                </div>
                <div style="height: 10px"></div>
                <table class="table table-bordered table-hover">                        
                    <tr class="active">                                    
                        <th>Khách Hàng</th>
                        <th>MSSV</th>
                        <th>Lop</th>
                        <th>SĐT</th>
                        <th>Ngày Sinh</th>                                                                        
                        <th>Địa Chỉ</th>
                        <th>Hồ Sơ</th>
                        <th>Ngay Dat</th>
                        <th>Ngay Nhan</th>
                        <th>Ghi Chu</th>
                        <th>Số Lượng</th>
                        <th>Đơn Giá</th>                            
                        <th>Thành Tiền</th>                            
                        <th>Người Nhận</th>                            
                        <th>Chọn</th>                            

                    </tr>  
                    <!-- BEGIN:dsdathang -->
                    <tr class="{TRANG_THAI}">                                
                        <td>{TEN_KH}</td>
                        <td>{MSSV}</td>
                        <td>{LOP}</td>
                        <td>{SDT}</td>
                        <td>{NGAY_SINH}</td>                                                                
                        <td>{DIA_CHI}</td>
                        <td>{TEN_HOSO}</td>
                        <td>{NGAY_DAT}</td>
                        <td>{NGAY_NHAN}</td>
                        <td>{GHI_CHU}</td>
                        <td>{SO_LUONG}</td>
                        <td>{DON_GIA}</td>
                        <td>{THANH_TIEN}</td>
                        <td>{TK_USERNAME}</td>
                        <td>                            
                            <input id="cb{ID_DATHANG}" name="cid[]" value="{ID_DATHANG}" type="checkbox">
                        </td>

                    </tr>                        
                    <!-- END:dsdathang -->
                </table>

            </div>
        </div>
    </div>
</div>
<!-- END:main -->